#region License, Terms and Conditions
//
// Jayrock - A JSON-RPC implementation for the Microsoft .NET Framework
// Written by Atif Aziz (www.raboof.com)
// Copyright (c) Atif Aziz. All rights reserved.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
//
#endregion

#if !NET_1_0 && !NET_1_1 && !NET_2_0

namespace Jayrock.Json.Conversion.Converters
{
    #region Imports

    using System;
    using System.Data;
    using System.Dynamic;
    using System.Text;
    using NUnit.Framework;

    #endregion

    [ TestFixture ]
    public class TestExpandoObjectExporter
    {
        [ Test ]
        public void Superclass()
        {
            Assert.IsInstanceOfType(typeof(ExporterBase), new ExpandoObjectExporter());
        }

        [ Test ]
        public void InputTypeIsExpandoObject()
        {
            Assert.AreSame(typeof(ExpandoObject), (new ExpandoObjectExporter()).InputType);
        }

        [Test]
        public void Export()
        {
            var context = JsonConvert.CreateExportContext();
            dynamic obj = new ExpandoObject();
            obj.num = 123;
            obj.flag = true;
            obj.str = "foobar";
            obj.nums = new[] { 123, 456, 789 };
            var json = new StringBuilder();
            new ExpandoObjectExporter().Export(context, obj, JsonText.CreateWriter(json));
            Assert.AreEqual("{\"num\":123,\"flag\":true,\"str\":\"foobar\",\"nums\":[123,456,789]}", json.ToString());
        }
    }
}

#endif // !NET_1_0 && !NET_1_1 && !NET_2_0
